<template>
  <div>
    <!-- 顶部导航 -->
    <header>
      <img src="@/assets/logo.png" alt="红梅食品 Logo" style="max-height: 35px;"/>
      <button class="menu-toggle" @click="toggleMenu">☰</button>
      <nav v-bind:class="{ active: menuActive }">
        <a href="indexPage.vue">首页</a>
        <a href="introduction.vue">红梅简介</a>
        <a href="material.vue">原料介绍</a>
        <a href="makeProduct.vue">制作过程</a>
        <a href="superMarket.vue">开始投放市场</a>
      </nav>
    </header>

    <!-- 互动区域 -->
    <div class="container">
      <div class="interactive-area">
        <p>将各种原料加入容器，发酵，然后看看结果！</p>
        <button @click="addIngredient">加入原料</button>
        <button @click="ferment">发酵</button>
        <button @click="crystallize">结晶</button>
        <div class="output" v-html="output"></div>
      </div>
    </div>

    <!-- 页脚 -->
    <footer>
      <p>红梅食品 创造生活高品质</p>
      <p>HONGMEI FOOD CREATES HIGH QUALITY OF LIFE</p>
    </footer>
  </div>
</template>

<script>
export default {
  data() {
    return {
      step: 0,  // 当前步骤
      output: "等待操作...",  // 输出内容
      menuActive: false  // 菜单是否激活
    };
  },
  methods: {
    // 加入原料
    addIngredient() {
      this.output = '原料已加入容器中！';
      this.output += '<div><img src="@/assets/原料.gif" alt="加入原料" style="width: 150px; height: 120px;"></div>';
      this.step = 1;
    },

    // 发酵操作
    ferment() {
      if (this.step === 1) {
        this.output = '发酵中，请稍候...';
        this.output += '<div><img src="@/assets/制作中.gif" alt="开始制作" style="width: 150px; height: 120px;"></div>';
        this.step = 2;
      } else {
        this.output = '请先加入原料！';
      }
    },

    // 结晶操作
    crystallize() {
      if (this.step === 2) {
        this.output = '发酵完成，结晶出现了！';
        this.output += '<div><img src="@/assets/结晶.gif" alt="出现结晶" style="width: 150px; height: 120px;"></div>';
        this.step = 3;
      } else {
        this.output = '请先完成发酵过程！';
      }
    },

    // 切换菜单
    toggleMenu() {
      this.menuActive = !this.menuActive;
    }
  }
};
</script>

<style scoped>
/* 全局样式 */
body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  background-color: #f9f9f9;
  line-height: 1.6;
}

header {
  background-color: #d00000;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  position: relative;
}

header img {
  max-height: 50px;
}

.menu-toggle {
  display: none;
  font-size: 1.5rem;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
}

nav {
  display: flex;
  gap: 1rem;
}

nav a {
  color: white;
  text-decoration: none;
  font-size: 1rem;
}

nav a:hover {
  text-decoration: underline;
}

nav.active {
  display: flex !important;
}

.container {
  margin: 1rem auto;
  padding: 1rem;
  max-width: 640px;
  background-color: white;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
}

.interactive-area {
  margin: 2rem 0;
  padding: 1rem;
  background: #f4f4f4;
  border-radius: 8px;
  text-align: center;
}

.interactive-area button {
  padding: 0.5rem 1rem;
  margin: 0.5rem;
  border: none;
  border-radius: 4px;
  background-color: #d00000;
  color: white;
  cursor: pointer;
  font-size: 1rem;
}

.interactive-area button:hover {
  background-color: #a00000;
}

.output {
  margin-top: 1rem;
  padding: 1rem;
  background: #e0ffe0;
  border-radius: 8px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: bold;
}

footer {
  background-color: #d00000;
  color: white;
  text-align: center;
  padding: 1rem 0;
  margin-top: 2rem;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }

  nav {
    display: none;
    flex-direction: column;
    background-color: #d00000;
    position: absolute;
    top: 100%;
    right: 0;
    width: 100%;
    padding: 1rem 0;
  }

  nav a {
    padding: 0.5rem 1rem;
  }
}
</style>
